<?php
	
	if(!$messages):
?>
	<h1><?php echo __('No Message Present',true)?></h1>
<?php  else:?>
	<ul>
	<?php foreach($messages as $message):?>
		<li>
			<div>
				Subject : <?php echo $message['Message']['subject']?><br />
				Body : <?php echo $message['Message']['body']?><br />
				Dated : <?php echo $message['Message']['created']?>
				<?php  if($message['Attachment']['id']) : ?>
				Attachment :  <?php echo $html->link($message['Attachment']['name'],'/uploads/attachment/'.$message['Attachment']['name'],array('target'=>'__blank'))?>
				<?php  endif; ?>
			</div>
		</li>
	<?php  endforeach;?>
	</ul>
<?php 
	if($messages[0]['Message']['recipient_type']==$session->read('Auth.model') && $messages[0]['Message']['recipient_id']==$session->read('Auth.'.$session->read('Auth.model').'.id'))
	{
		$recipientId = $messages[0]['Message']['recipient_id'];
		$recipientType = $messages[0]['Message']['recipient_type'];
	}else
	{
		$recipientId = $messages[0]['Message']['sender_id'];
		$recipientType = $messages[0]['Message']['sender_type'];
	}
?>
<?php echo $this->element('message_form',array('recipientType'=>$recipientType,'recipientId'=> $recipientId,'threadId'=>$this->params['pass'][0]))?>
<?php endif;?>